package com.zhiyin.seal.constant;

import java.util.Arrays;
import java.util.Optional;

/**
 * 报警类型
 */
public enum AlarmTypeEnum implements BaseEnum {
    PRESS(0, "长按报警"),

    PULL_DOWN(1, "防拆报警");

    private Integer value;
    private String desc;

    AlarmTypeEnum(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    @Override
    public Integer getValue() {
        return value;
    }
    @Override
    public String getDesc() {
        return desc;
    }

    public static AlarmTypeEnum valueOf(Integer status) {
        AlarmTypeEnum[] values = AlarmTypeEnum.values();
        Optional<AlarmTypeEnum> first = Arrays.stream(values).filter(e -> e.getValue().equals(status)).findFirst();
        return !first.isPresent() ? null : first.get();
    }

    public static boolean isExist(Integer status) {
        AlarmTypeEnum judgeEnum = valueOf(status);
        return judgeEnum != null;
    }
}
